{template "header.html", "/"}

<div class="page-container">
    <div class="page-content-wrapper">
        <div class="page-content bg-h">
            <div class="container">


                <ul class="page-breadcrumb breadcrumb">
                    <li><a href="{SITE_URL}">首页</a><i class="fa fa-angle-right"></i></li>
                    {if defined('IS_SHARE') && !IS_SHARE}
                    <li><a href="{MODULE_URL}">{MODULE_NAME}</a><i class="fa fa-angle-right"></i></li>
                    {/if}
                    {dr_catpos($catid, '', 1, '<li><a href="{url}">{name}</a><i class="fa fa-angle-right"></i></li>'.PHP_EOL)}
                    <li> <span>贴子</span></li>
                </ul>

                <div class="bbs-content row">

                    <div class="col-md-8">

                        <div class="news-body">
                            <h4 class="title">{$title}</h4>
                            <div class="title-btn">
                                <label>
                                    <i class="fa fa-user"></i> {$author}
                                </label>
                                <label>
                                    <i class="fa fa-calendar"></i> {$updatetime}
                                </label>
                                <label>
                                    <i class="fa fa-eye"></i> {dr_show_hits($id)}次
                                </label>
                                <label class="">
                                    <i class="fa fa-comments"></i> {$comments}
                                </label>
                                <label class="">
                                    <i class="fa fa-flag"></i>  <a href="javascript:dr_module_favorite('{MOD_DIR}', '{$id}', 0);">加入收藏</a>
                                </label>
                            </div>

                            <div class="news-content">
                                {$content}
                            </div>
                            <div class="news-keyword">
                                <div class="news-keyword-tags">
                                    {loop $keyword_list $name $url}
                                    <label>
                                        <a href="{$url}" target="_blank">{$name}</a>
                                    </label>
                                    {/loop}
                                </div>
                            </div>
                        </div>
                        <div class="news-comments-top">
                            <h4>网友回帖</h4>
                            <div class="count"><span class="num">{$comments}</span>条回帖</div>
                        </div>
                        <div class="news-comments-body">
                            <?php
                        $comment = dr_comment(SITE_ID.'_'.MOD_DIR, $id);
                        $comment_table = SITE_ID.'_'.MOD_DIR.'_comment_data_'.(int)$comment['tableid'];
                        $comment_url = dr_url(MOD_DIR.'/comment/add', array('id' => $id));
                            $last_page_url = $url;
                            ?>
                            {table table=$comment_table cid=$id status=1 order=inputtime_asc page=1 pagesize=10 urlrule=$urlrule cache=10}
                            <div class="bbs-comments-item">
                                <div class="row">
                                    <div class="col-md-2 text-center wbbs_avatar">
                                        {php $user=dr_member_info($t.uid);}
                                        <p class="wbbs_avatar_url"><img src="{$user.avatar_url}"></p>
                                        <p>{$user.username}</p>
                                        <p >{$user.groupname}</p>
                                    </div>
                                    <input type="hidden" id="dr_comment_{$t.id}" value="{php echo $user ? $user.username : 'undefined';}">
                                    <input type="hidden" id="dr_blockquote_{$t.id}" value="{dr_strcut(dr_clearhtml($t.content), 100)}">
                                    <div class="col-md-10 wbbs_show">
                                        <div class="portlet-title">
                                            <div class="caption">
                                                <span class="caption-subject font-dark">
                                                    回复于: {dr_fdate($t.inputtime)}
                                                </span>
                                                <span class="wbbs_reply">
                                                    <a href="javascript:dr_reply_comment({$t.id});" class=""><i class="fa fa-plus-square"></i> 回帖</a>
                                                </span>
                                            </div>
                                        </div>

                                        <div class="portlet-body">
                                            {$t.content}
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {/table}
                            <?php $last_page_url = str_replace('{page}', ceil($total/$pagesize), $urlrule); ?>


                            <div class="news-list-pagination">
                                <ul class="pagination">
                                    {$pages}
                                </ul>
                            </div>

                            <div class="bbs-comments-item" style="border-bottom: 0">
                                <div class="row">
                                    <div class="col-md-2 text-center wbbs_avatar">
                                        <p class="wbbs_avatar_url"><img src="{$member.avatar_url}"></p>
                                        <p>{$member.username}</p>
                                        <p >{$member.groupname}</p>
                                    </div>
                                    <div class="col-md-10 wbbs_show">
                                        <div class=" ">
                                            <div class="portlet-body">


                                                <form action="" id="myform" method="post" class="form-horizontal" novalidate>
                                                    <div class="form-body">

                                                        <div class="form-group">
                                                            <div class="col-md-12">
                                                                <script type="text/javascript">var DR_DIV2P = true;</script>
                                                                <script type="text/javascript" src="/api/ueditor/ueditor.config.js"></script>
                                                                <script type="text/javascript" src="/api/ueditor/ueditor.all.js"></script>
                                                                <script type="text/javascript" src="/api/ueditor/lang/zh-cn/zh-cn.js"></script>
                                                                {dr_field_input('content', 'Ueditor', array('option' => array( 'mode' => 3, 'height' => 220, 'width' => '100%', 'tool' => '\'simpleupload\', \'attachment\', \'insertimage\', \'insertcode\''), 'validate' => array('xss' => 1)))}
                                                            </div>
                                                        </div>
                                                    </div>
                                                    {if $ci->get_cache('comment', 'comment-module-'.MOD_DIR, 'value', 'permission', $markrule, 'code')}
                                                    <div class="form-group" id="dr_row_code">
                                                        <div class="col-md-4">
                                                            <label>
                                                                <div class="form-recaptcha">
                                                                    <div class="input-group">
                                                                        <input type="text" id="dr_code" class="form-control" name="code">
                                                                        <div class="input-group-btn fc-code">
                                                                            {dr_code(120, 35)}
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </label>
                                                        </div>
                                                    </div>
                                                    {/if}

                                                    <div class="form-actions">
                                                        <div class="row">
                                                            <div class="col-md-12">
                                                                <button class="mysubmit btn default" type="button" onclick="dr_post_comment()"> 回复贴子 </button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </form>


                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>


                            <script language="javascript">
                                // 评论提交
                                function dr_post_comment() {
                                    $.ajax({
                                        type: "POST",
                                        dataType: "json",
                                        url: "{$comment_url}",
                                        data: $("#myform").serialize(),
                                        success: function(data) {
                                            if (data.status == 1) {
                                                dr_tips(data.code, 3, 1);
                                                // 刷新页面
                                                window.setTimeout("window.location.href='{$last_page_url}'", 2000);
                                            } else {
                                                dr_tips(data.code)
                                            }
                                        },
                                        error: function(HttpRequest, ajaxOptions, thrownError) {}
                                    })
                                }
                                function dr_reply_comment(id) {
                                    var valc =  $.trim($('#dr_comment_'+id).val());
                                    if (valc =='' || valc == undefined || valc == 'undefined') {
                                        // 不管
                                    } else {
                                        var html = '@'+valc;
                                        html+= '<blockquote>'+$('#dr_blockquote_'+id).val()+'</blockquote>';
                                        html+= '<p></p><br>';
                                        UE.getEditor('dr_content').setContent( html + '  '+ UE.getEditor('dr_content').getContent() );
                                    }
                                    $('html,body').animate({scrollTop:$('#myform').offset().top}, 800);
                                }
                            </script>
                        </div>

                    </div>

                    <div class="col-md-4">

                        <div class="bbs-table">
                            <div class="bbs-table-title">论坛版块</div>
                            <div class="bbs-list">

                                <div class="layui-clear bbs-list-quick">
                                    {if $related}
                                    {loop $related $t}
                                    <div class="layui-col-xs6">
                                        <div class="{if $t.id==$catid}on{/if}"><a href="{$t.url}">{$t.name}</a></div>
                                    </div>
                                    {/loop}
                                    {else}
                                    {category pid=0}
                                    <div class="layui-col-xs6">
                                        <div>
                                            <a href="{$t.url}">{$t.name}</a></div>
                                    </div>
                                    {/category}
                                    {/if}
                                    <div class="layui-clear"></div>
                                </div>
                                
                            </div>
                        </div>

                        <div class="bbs-table">
                            <div class="bbs-table-title">热门讨论</div>
                            <ul class="bbs-list-tz">
                                {module num=10 catid=$catid order=comments}
                                <li> <a href="{$t.url}">{dr_strcut($t.title, 20)}</a> <i class="fa fa-comments"></i> {$t.comments}</li>
                                {/module}
                            </ul>
                        </div>

                        <div class="bbs-table">
                            <div class="bbs-table-title">人气贴子</div>
                            <ul class="bbs-list-tz">
                                {module num=10 catid=$catid order=hits}
                                <li> <a href="{$t.url}">{dr_strcut($t.title, 20)}</a> <i class="fa fa-eye"></i> {$t.hits}</li>
                                {/module}
                            </ul>
                        </div>

                    </div>


                </div>




            </div>
        </div>
    </div>
</div>

{template "footer.html", "/"}